package config

import "mall/common/utils"

const (
	SeckillOrderExchangeName = "seckill.order.exchange"

	SeckillOrderQueueName = "seckill.order.queue"

	SeckillOrderRoutingKey = "seckill.order"
)

func init() {
	channel, _ := utils.GetRabbitMQChannel()

	// 声明交换机
	err := channel.ExchangeDeclare(SeckillOrderExchangeName, "direct", true, false, false, false, nil)

	// 声明队列
	queue, err := channel.QueueDeclare(SeckillOrderQueueName, true, false, false, false, nil)

	// 声明bind
	err = channel.QueueBind(queue.Name, SeckillOrderRoutingKey, SeckillOrderExchangeName, false, nil)

	if err != nil {
		panic(err)
	}

}
